package com.nantian.common.secret.sm;

import com.nantian.common.secret.HexUtils;
import org.bouncycastle.math.ec.ECPoint;

import java.math.BigInteger;

/**
 * <p>ClassName: Sm2KeyPairUtils</p>
 * <p>Description: SM2密钥对Bean</p>
 * <p>Copyright: Copyright©2014</p>
 * <p>Company: 广州南天电脑系统有限公司</p>
 * <p>Date: 2020-06-03</p>
 *
 * @author 刘晓辉
 * @version 1.0
 */
public class Sm2KeyPairUtils {

    private final ECPoint publicKey;
    private final BigInteger privateKey;

    public Sm2KeyPairUtils(ECPoint publicKey, BigInteger privateKey) {
        this.publicKey = publicKey;
        this.privateKey = privateKey;
    }

    public ECPoint getPublicKey() {
        return publicKey;
    }

    public BigInteger getPrivateKey() {
        return privateKey;
    }

    public String getPublicKeyHex() {
        byte[] pubByte = publicKey.getEncoded(false);
        return HexUtils.bytesToHexString(pubByte);
    }

    public String getPrivateKeyHex() {
        byte[] priByte = HexUtils.bitIntegerToBytes(privateKey);
        return HexUtils.bytesToHexString(priByte);
    }

}

